package com.atguigu.flink.day03;

import org.apache.flink.api.common.eventtime.WatermarkStrategy;
import org.apache.flink.connector.file.src.FileSource;
import org.apache.flink.connector.file.src.reader.TextLineInputFormat;
import org.apache.flink.core.fs.Path;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @author Felix
 * @date 2023/12/2
 * 该案例演示了源算子---从文件中读取数据
 */
public class Flink03_source_file {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        // env.readTextFile("");
        FileSource<String> fileSource =
             FileSource.forRecordStreamFormat(new TextLineInputFormat(), new Path("D:\\dev\\workspace\\bigdata0710-parent\\flink0710\\input\\word.txt"))
             .build();
        DataStreamSource<String> fileDS
            = env.fromSource(fileSource, WatermarkStrategy.noWatermarks(), "file_source");

        fileDS.print();

        env.execute();
    }
}
